package Test;

import java.util.concurrent.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:38917
 * Date:2025/4/15
 * Time:20:16
 */
public class Test {
    public static void main(String[] args) {
        //
        ThreadPoolExecutor executor = new ThreadPoolExecutor(2,2,0, TimeUnit.MINUTES,
                new ArrayBlockingQueue<>(2),
                Executors.defaultThreadFactory(),new ThreadPoolExecutor.DiscardOldestPolicy());
        for (int i = 0; i < 10; i++) {
            int finalI = i;
            executor.execute(()-> System.out.println(Thread.currentThread().getName() + "       执行任务:" + finalI));
        }
    }
}
